<template>
	<view class="container">
		<view class="sub_title">
			<text>{{title}}</text>
		</view>
		<view class="input">
			<u--textarea fixed='true' v-model="value" type='textarea' border='surround' maxlength='500' height='300rpx' placeholder='请输入' />
		</view>
		<view class="submit" @click="submitTap">保存</view>
		<!-- <view class="submit" v-else style="background-color: #999999;">保存</view> -->
	</view>
</template>

<script>
	import {
		user
	} from '@/api/user.js'
	export default{
		data() {
			return {
				userInfo: {},
				value: '',
				name: '',
				title: ''
			}
		},
		onLoad() {
			this.value = decodeURIComponent(this.$Route.query.content)
			this.name = this.$Route.query.name
			this.title = this.$Route.query.title
		},
		methods:{
			submitTap(){
				this.updateUserInfo()
			},
			updateUserInfo(){
				
				if(this.value == decodeURIComponent(this.$Route.query.content)){
					uni.navigateBack()
					return
				}
				var value = this.$tools.emojiToEntities(this.value)
				if(value.length > 500){
					uni.showToast({
						title: "最多只能输入500个字符",
						icon: 'none'
					})
					return
				}
				var params = {}
				switch (this.name){
					case 'zwms':
						params = {intro_zwms: value}
						break;
					case 'xqah':
						params = {intro_xqah: value}
						break;
					case 'lxlyb':
						params = {intro_lxlyb: value}
						break;
					default:
						break;
				}
				
				user.updateUser(params).then(res => {
					if(res.data.code == 10000){
						uni.navigateBack()
						uni.showToast({
							title: '保存成功',
							icon: 'none'
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #FFFFFF;
		height: 100vh;
	}
	.sub_title{
		width: 690rpx;
		margin-top: 60rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		font-size: 26rpx;
		text:nth-of-type(1){
			background-color: #f1f1ff;
			color: #637bd6;
			border-radius: 25rpx;
			font-weight: bold;
			padding: 8rpx 16rpx;
		}
	}
	.input{
		width: 690rpx;
		margin-top: 40rpx;
	}
	.submit{
		margin-top: 200rpx;
		background-color: #7893ff;
		color: #FFFFFF;
		text-align: center;
		width: 300rpx;
		height: 80rpx;
		line-height: 80rpx;
		border-radius:40rpx;
		font-size: 28rpx;
	}
</style>
